GenerateSortedPermutations Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Generates all the possible permutations of the items in collection, in lexicographical order. Even if some items are equal, the same permutation will not be generated more than once. For example, if the collections contains the three items A, A, and B, then this method will generate only the three permutations, AAB, ABA, BAA.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static IEnumerable<T[]> GenerateSortedPermutations<T>(
	IEnumerable<T> collection
) where T : Object, IComparable<T>
Visual Basic (Declaration)
Public Shared Function GenerateSortedPermutations(Of T As {Object, IComparable(Of T)}) ( _
	collection As IEnumerable(Of T) _
) As IEnumerable(Of T())
Visual C++
public:
generic<typename T>
where T : Object, IComparable<T>
static IEnumerable<array<T>^>^ GenerateSortedPermutations (
	IEnumerable<T>^ collection
)

Parameters

collection
IEnumerable<(Of <T>)>
The collection of items to permute.

Return Value

An IEnumerable<T[]> that enumerations all the possible permutations of the items in collection. Each permutations is returned as an array. The items in the array should be copied if they need to be used after the next permutation is generated; each permutation may reuse the same array instance.

Type Parameters

T
The type of items to permute.

See Also